/**
 * Created with IntelliJ IDEA.
 * Description:类和对象3
 * User: liangyuanzhang
 * Date: 2024-12-10
 * Time: 10:12
 */
class Student {
    private String name = "wangda";
    private int age;
    private double score;
    private static String className = "113";

    //当类加载的时候 就会被触发
    static {
        //定义在类当中，方法的外边  一般用来初始化静态的成员变量。
        className = "114";
        //name = "fafa";error
        System.out.println("静态代码块当中 一" +
                "般用来初始化" +
                "静态成员变量...");
    }

    {
        this.name = "gaobo";
        System.out.println("实例代码块......");
    }
    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
        //className = "FDSAF";
        System.out.println("构造方法执行了....");
    }

    public Student() {

        System.out.println("Student() 构造方法执行了....");
    }

    public static void setClassName(String className) {
        Student.className = className;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public void doClass() {
        System.out.println(this.name+" 正在上课.....");
    }

    public void show() {
        System.out.println("姓名："+this.name +" 年龄："
                +this.age+" 成绩："+this.score);
        //getClassName();
    }

    public String toString() {
        return "Student{" +
                "姓名='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
        /*return "gaobo 很帅！";*/
    }

    /*
        静态成员方法 -> 类方法 -> 不依赖于对象。
         */
    public static String getClassName() {
        //this.name = "fsfsa"; error
        /*Student student = new Student("lisi",10,12.4);
        student.show();*/
        return className;
    }
}

public class Test {

    public static void main(String[] args) {
        Student student1 = new Student("lisi",10,12.4);
        System.out.println(student1.toString());
    }

    public static void main7(String[] args) {
        Student student1 = new Student();

        System.out.println("==========");

        Student student2 = new Student();

        //System.out.println(student1.getName());
    }

    public static void main6(String[] args) {
        Student student1 = new Student("lisi",10,12.4);
        //System.out.println(Student.getClassName());
        System.out.println(student1.getName());
    }

    public static void main5(String[] args) {

        {
            int a = 20;
            System.out.println(a);
        }

        //System.out.println(a);  不包含在 作用域当中

    }

    public static void main3(String[] args) {
        Student student1 = null;
        System.out.println(student1.getClassName());
    }
    public static int add(int a,int b) {
        if(a > 10) {

        }
        return a + b;
    }
    public static void main2(String[] args) {
        System.out.println(add(1, 2));

        /*Student student1 = new Student("lisi",10,12.4);
        student1.show();
        */

        System.out.println(Student.getClassName());


        //System.out.println(student1.getClassName());

    }
    public static void main1(String[] args) {
        Student student1 = new Student("lisi",10,12.4);
        student1.show();

        Student student2 = new Student("zhangsan",5,90);
        student2.show();

        Student student3 = new Student("wangwu",60,80);
        student3.show();

    }
}